/* 
 * File:   main.cpp
 * Author: Vicky.H
 * Email:  eclipser@163.com
 */
#include "User.h"
#include "SayHello.h"
#include "tarray.h"
#include <iostream>
#include <lua.hpp> // -llua-5.1


int  tolua_User_open (lua_State* tolua_S);
int  tolua_SayHello_open (lua_State* tolua_S);
int  tolua_tarray_open (lua_State* tolua_S);

/*
 * 
 */
int main(void) {

    CUser user("Vicky", "123456", 26);
    std::cout << user << std::endl;
    
    std::cout << "\n---------------------------" << std::endl;
    

    lua_State* L = lua_open();
    luaL_openlibs(L);
    
    tolua_User_open(L);
    
    luaL_dofile(L, "main.lua");
    
    std::cout << "\n---------------------------" << std::endl;
    
    func::sayHello();
    
    tolua_SayHello_open(L);
    
    luaL_dofile(L, "SayHello.lua");
    
    std::cout << "\n---------------------------" << std::endl;
    
    int i;
    for (i = 0; i < 10; ++i) {
        pp[i] = &p[i];

        ma[i] = a[i];
        mp[i] = p[i];
        mpp[i] = pp[i];

        array.a[i] = a[i];
        array.p[i] = p[i];
        array.pp[i] = pp[i];
    }
    
    tolua_tarray_open(L);
    
    luaL_dofile(L, "tarray.lua");
    
    lua_close(L);
    return 0;
}
